package cn.qidisoft.edu.hzjt.controller.zyc;

import cn.qidisoft.edu.hzjt.controller.BaseController;
import cn.qidisoft.edu.hzjt.model.Semester;
import cn.qidisoft.edu.hzjt.model.xb.PartyInfomationEn;
import cn.qidisoft.edu.hzjt.model.zyc.DyScore;
import cn.qidisoft.edu.hzjt.model.zyc.PartyBranch;
import cn.qidisoft.edu.hzjt.model.zyc.PartyNotice;
import cn.qidisoft.edu.hzjt.service.ICommonService;
import cn.qidisoft.edu.hzjt.service.xb.IPartyInfomationService;
import cn.qidisoft.edu.hzjt.service.zyc.IDangjianService;
import cn.qidisoft.edu.hzjt.service.zyc.IDzbService;
import cn.qidisoft.edu.hzjt.service.zyc.IPartyNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @descripition 党建园地
 */
@Controller
@RequestMapping(value = "/dangjian/")
public class DangjianController {


    @Autowired
    private IPartyInfomationService partyInfomationService;
    
    @Autowired
    private IDangjianService dangjianService;
    
    @Autowired
    private IDzbService dzbService;
    
    @Autowired
	private ICommonService commonService;

    @Autowired
    private IPartyNoticeService partyNoticeService;
    
    

    /**
     * 1: 首页
     * @param request
     * @return
     */
    @RequestMapping(value = "index")
    public String index(ModelMap model,HttpServletRequest request){
    	
    		// 获取当前学期信息
    		BaseController.getSemester(model, commonService);
    		
    		Semester semester = (Semester) model.get("semester");
    		Integer semId = semester.getXqid();
    	
    		//资讯
        PartyInfomationEn partyInfomationEn = new PartyInfomationEn();
        List<PartyInfomationEn> partyInfomationEnList = partyInfomationService.queryList(partyInfomationEn);
        request.setAttribute("partyInfomationEnList",partyInfomationEnList);
        
        //党员分数
        Map<String, Object> paramterMap = new HashMap<String, Object>();
        paramterMap.put("semId", semId);
        List<DyScore> dyScoreList = dangjianService.getDyScore(paramterMap);
        request.setAttribute("dyScoreList",dyScoreList);
        
        //获取党支部
        List<PartyBranch> partyBranchList = dzbService.getDzbList(null);
        request.setAttribute("partyBranchList",partyBranchList);

        //获取公告公示
        List<PartyNotice> pList =  partyNoticeService.getpartyNoticeEight();
        request.setAttribute("pList",pList);
        
        
        return "zyc/dangjian/index";
    }

    /**
     * 导航页
     * @param request
     * @return
     */
    @RequestMapping(value = "n_second")
    public String n_second(HttpServletRequest request){
        return "zyc/dangjian/n_second";
    }


    /**
     * 公告详情页
     * @param request
     * @return
     */
    @RequestMapping(value = "notice_detail")
    public String notice_detail(HttpServletRequest request){
        String gGid = request.getParameter("gGid");
        PartyNotice partyNotice = partyNoticeService.getByGgId(Integer.parseInt(gGid));
        request.setAttribute("notice",partyNotice);
        return "zyc/dangjian/notice_detail";
    }

    /**
     * 党建资讯详情页
     * @param request
     * @return
     */
    @RequestMapping(value = "infomation_detail")
    public String infomation_detail(HttpServletRequest request){
        String infoId = request.getParameter("infoId");
        PartyInfomationEn partyInfomationEn  = partyInfomationService.getBydangjianId(Integer.parseInt(infoId));
        request.setAttribute("partyInfomationEn",partyInfomationEn);
        return "zyc/dangjian/infomation_detail";
    }

}
